import { message, notification } from 'ant-design-vue'
import router from '@/router' // 路由
import VueCookies from 'vue-cookies' //cookies
const vueCookies: any = VueCookies
export function  useMessage(title: string, type: string) {
  message[type](title)
}
type Direction = 'success' | 'info' | 'warning' | 'error'
const messageMap = {
  'success':'成功',
  'info':'信息',
  'warning':'警告',
  'error':'错误',
}
export function useNotif(title: string, type: Direction, isLnvalid?: boolean) {
  notification[type]({
    message: messageMap[type],
    description: title,
  })
  if (isLnvalid) {
    vueCookies.remove('userInfo')
    router.push('/login')
  }
}
